package org.example.springboot01.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springboot01.pojo.Article;

import java.util.List;

@Mapper
public interface Articlemapper {
    @Insert("insert into columns(title,content,cover_img,state,category_id,creater_user,create_time,update_time)" +
            "values(#{title},#{content},#{coverImg},#{state},#{categoryId},#{createrUser},#{createTime},#{updateTime})")
    void addarticle(Article article);

    List<Article> list(String username, Integer categoryId, String state);

   @Select("select * from columns where id=#{id}")
    Article getarticle(Integer id);
   @Update("update columns set title=#{article.title},content=#{article.content},cover_img=#{article.cover_img},state=#{article.state},category_id=#{article.category_id},update_time=#{article.update_time} where id=#{id}")
    void updatearticle(@Param("article") Article article,@Param("id") Integer id);
    @Delete("delete from columns where id=#{id}")
    void deletearticle(Integer id);
}
